import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import routes from './router'
import http from './utils/http'
import './assets/style/index.css'
Vue.use(VueRouter);
Vue.config.productionTip = false;
function getQueryString(name) {
    let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
    let r = window.location.search.substr(1).match(reg);
    let h = null;
    if (window.location.hash.split('?')[1]) {
        h = window.location.hash.split('?')[1].match(reg);
    }
    if (r != null) {
        return unescape(r[2]);
    } else if (h != null) {
        return unescape(h[2]);
    }
    return null;
}
let wxId = getQueryString('wxId')
if (wxId) {
    localStorage.setItem('wxId', wxId)
} else {
    wxId = localStorage.getItem('wxId')
}
const router = new VueRouter(routes);
router.beforeEach((to, from, next) => {
    console.log(to, from, 'to, from');
    if (to.fullPath === from.fullPath) return;
    document.title = to.name;
    next();
});
Vue.prototype.$http = http;
console.log(wxId);
new Vue({
    router,
    data: {
        userInfo: null,
        index: null,
        wxId
    },
    render: h => h(App),
}).$mount('#app');
